<%--
  Created by IntelliJ IDEA.
  User: 王润
  Date: 2017/7/26
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title>人事调度</title>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" type="text/css" href="../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base.css">
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .headDiv {
            width: 100%;
            height: 45px;
            border-bottom: #999 1px solid;
            overflow: hidden;
        }

        .main_title li {
            width: 135px;
            height: 28px;
            line-height: 28px;
            display: inline-block;
            float: left;
            font-family: Microsoft yahei,Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;
            font-size: 14px;
            margin-left: 20px;
            margin-top: 10px;
            cursor: pointer;
            text-align: center;
            font-weight: 700;
            border-radius: 10px;
        }

        .main_title .title_on {
            background: #2F8AE3;
            color: white;
        }

        .head {
            margin-top: 10px;
            height: 33px;
        }

        .head .title {
            margin-left: 22px;
            float: left;
        }

        .head span {
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }

        label select {
            width: 130px;
            padding-left: 10px;
            height: 32px;
            left: 20px;
        }

        .fl input {
            padding: 0 10px;
            width: 130px
        }

        #pagediv #pageTbody input[name="checkbox"] {
            display: inline-block;
        }

        .pagediv .page-bottom-outer-layer table td:last-child {
            font-weight: normal;
            overflow: hidden;
            white-space: pre;
            height: 40px;
            padding: 4px;
            box-sizing: border-box;
            text-overflow: ellipsis;
            font-size: 11pt;
            text-align: left;
            border-right: 1px solid #ddd;
        }

        .sel li {
            line-height: 24px;
            color: #000;
        }

        #list img {
            margin-top: -2px;
            margin-left: 0px;
        }

        .pBeforeLa p {
            position: relative;
        }

        .inp_sel {
            width: 100%;
            padding-top: 25px;
            margin-bottom: 60px;
        }

        .inp_sel input {
            margin-left: 10px;
            width: 170px;
            border: 1px solid rgb(204, 204, 204);
            border-radius: 5px;
            padding-left: 5px;
        }

        .inp {
            height: 40px;
            float: left;
            margin-left: 16px;
            border-radius: 3px;
            font-size: 10pt;
            margin-bottom: 8px;
        }

        #j_tb tr {
            height: 40px;
            line-height: 40px;
        }

        #j_tb {
            height: 400px;
        }

        select, textarea {
            width: 148px;
            height: 29px;
            line-height: 29px;
            border-radius: 4px;
            margin-right: 10px;
        }

        #checkOut {
            width: 50px;
            height: 30px;
            background: url(../../img/address/shape.png) no-repeat;
            background-size: 14px;
            background-color: #2d7de0;
            color: white;
            text-align: center;
            background-position: 11px 7px;
            padding-left: 21px;
            cursor: pointer;
            line-height: 30px;
        }

        table input, .bottom input {
            width: 17px;
            cursor: pointer;
        }

        select {
            cursor: pointer;
        }

        .bottom {
            height: 30px;
            line-height: 30px;
            /*border: 1px solid #c0c0c0;*/
            margin-top: -1px;
            background-color: #fff;
        }

        .bottom div {
            float: left;
            height: 85%;
            font-size: 14px;
            font-weight: normal;
        }

        .allTrue {
            text-align: center;
        }

        #userDept {
            vertical-align: middle;
            margin-left: 5px;
            border-width: 1px;
            border-style: solid;
            border-color: rgb(153, 153, 153);
            border-image: initial;
        }

        .layui-layer {
            text-align: center;
        }

        .layui-layer .layuiDiv {
            margin-top: 20px;
        }

        .bottom .dispatchAll {
            width: 80px;
            height: 30px;
            background-color: #2d7de0;
            color: white;
            text-align: center;
            cursor: pointer;
            border-radius: 3px;
            line-height: 30px;
            margin-left: 16px;
        }

        .newClass{
            cursor: pointer;
            color: rgb(51, 161, 232);
            font-size: 14px;
            margin-right: 10px;
        }
        .oldClass{
            cursor: pointer;
            color: rgb(51, 161, 232);
            font-size: 14px;
            margin-right: 10px;
        }
        .One .inp {
            height: 40px;
            float: left;
            margin-left: 24px;
            border-radius: 4px;
        }

        .layuiDiv span {
            font-size: 21px;
        }

        .layuiDiv select {
            width: 300px;
            height: 40px;
            font-size: 18px;
        }

        .inp a {
            font-size: 13px;
        }

        tbody tr td:nth-child(1){
            width:78px!important;
            display: inline-block;
        }
    </style>
</head>
<body>
<div class="headDiv">
    <ul class="main_title">
        <li class=" title_on"><span class="headli1_1">当前人员分布表</span></li>
        <li style="width: 20px;margin-top: 6px;"><img class="headli1_2" src="../../img/twoth.png" alt=""></li>
        <li><span class="headli1_1">当前人员分布概况</span></li>

    </ul>
</div>
<div class="head" style="border-bottom: none">
    <div class="title">
        <img src="/img/commonTheme/theme6/flow_run_title.png">
        <span style="">人员调度</span>
    </div>
    <div class="inp" style="margin-left: 45px;">
        项目:
        <select class="project">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        部门:
        <input type="text" name="" id="deptment" user_id="" value="点击右侧添加" oninput="alert(1)" style="width: 150px"
               disabled>
        <a href="javascript:;" id="selectDept" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
        <a href="javascript:;" id="clearDept" style="color:red"><fmt:message code="global.lang.empty"/></a>
    </div>
    <div class="inp">
        职务:
        <select id="jobPosition">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        岗位:
        <select id="workJob">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        所在位置:
        <select class="location">
            <option>请选择..</option>
        </select>
    </div>
    <div class="inp">
        目标人：<input name="" id="userDuser" user_id="" value="点击右侧添加" style="width: 150px;" disabled/>
        <a href="javascript:;" id="selectUser" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
        <a href="javascript:;" id="clearUser" style="color:red"><fmt:message code="global.lang.empty"/></a>
    </div>
    <div class="inp" id="checkOut">查询</div>
</div>

<div class="tab">
    <table id="tr_td" style="table-layout: fixed;">

        <div style="margin-top: 55px;">
            <div colspan="8" class="th" style="text-align: left">
                <div class="bottom">
                    <div class="allTrue"><input type="checkbox" id="allChoose" style="margin-left: 11px;"/>全选</div>
                    <div class="dispatchAll">
                        批量调度
                    </div>
                </div>
            </div>
        </div>
        <tr>
            <td class="th" style="width: 6%;">选择</td>
            <td class="th" style="width: 9%;">姓名</td>
            <td class="th" style="width: 8%;">部门</td>
            <td class="th" style="width: 17%;">职务</td>
            <td class="th" style="width: 17%;">项目</td>
            <td class="th" style="width: 17%;">岗位</td>
            <td class="th" style="width:7%;">所在位置</td>
            <td class="th" style="width:20%;">操作</td>
        </tr>
        </div>
        <tbody id="j_tb">

        </tbody>
    </table>

    <%--<div class="bottom">--%>
        <%--<div class="allTrue"><input type="checkbox" id="allChoose" style="margin-left: 22px;"/>全选</div>--%>
        <%--<div class="dispatchAll">--%>
            <%--批量调度--%>
        <%--</div>--%>
    <%--</div>--%>
    <div class="right" style="margin-right: 6%;">
        <div style="margin: 0 auto;height:50px;width: 97%;" class="clearfix">
            <div id="dbgz_page" class="M-box3">

            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(document).on('click','.old_rdetails',function () {
        var staff = $(this).attr('staff');
        var id = $(this).attr('id');
        // window.location.href = "/hr/page/personnelInformation?staffId="+staff;
        $.popWindow("/hrPersonnelScheduling/jumpHrDispatcherDetails?staffId="+staff+"&id="+id);
    })

    $(document).on('click','.rdetails',function () {
        var staff = $(this).attr('staff');
        // window.location.href = "/hr/page/personnelInformation?staffId="+staff;
        $.popWindow("/hr/page/personnelInformation?staffId="+staff)
    })
    function getStr(obj) {
        var str111 = '';
        for (var x in obj) {
            // str111 += obj[x][0]['deptName'] + '（' + obj[x].length + '人）：';
            for (var i = 0; i < obj[x].length; i++) {
                str111 += obj[x][i]['name'] + ','
            }
            // str111 += '\n';
        }
        return str111
    }

    function checkDept(arrObj) {
        var arr = [];
        for (var x = 0; x < arrObj.length; x++) {
            arr.push(arrObj[x]['deptName'])
        }
        var newArr12 = uniq(arr);
        var dataNew = {};
        for (var x = 0; x < newArr12.length; x++) {
            var newArrArr = [];
            for (var i = 0; i < arrObj.length; i++) {
                if (arrObj[i]['deptName'] == newArr12[x]) {
                    newArrArr.push(arrObj[i]);
                }
            }
            dataNew[x] = newArrArr
        }
        return dataNew
    }

    $(".main_title li").eq(0).click(function () {
        window.location.href = "/hrPersonnelScheduling/peopleSchedulingList"

    });
    $(".main_title li").eq(2).click(function () {
        window.location.href = "/hrPersonnelScheduling/peopleSchedulingStatistics"
    });

    function ajaxTable(datt) {
        var ajaxPageLe = {
            data: {
                page: 1,//当前处于第几页
                pageSize: 20,//一页显示几条
                useFlag: true
            },
            page: function () {
                var me = this;
                // console.log(me.data.page);
                datt['page'] = me.data.page;
                datt['pageSize'] = me.data.pageSize;
                datt['userFlag'] = me.data.useFlag;
                $.ajax({
                    url: '/hrPersonnelScheduling/queryPeopleSchedulingList',
                    type: 'get',
                    data: datt,
                    dataType: 'json',
                    success: function (res) {
                        var datas = res.obj;
                        var str = "";
                        function checkInner(obj) {
                            if (obj == "" || typeof (obj) == "undefined") {
                                return " "
                            } else {
                                return obj
                            }
                        }

                        for (var x = 0; x < res.obj.length; x++) {
                            str += " <tr>\n" +
                                "            <td class='checkWrap'><input type=\"checkbox\" name=\"chkItem\" class='childCheck'> </td>\n" +
                                "            <td style='cursor: pointer;color: rgb(51, 161, 232)' class='rdetails' staff=" + res.obj[x]['staffId'] + " id=" + res.obj[x]["userId"] + ">" + checkInner(res.obj[x]["staffName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["deptName"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["jobPositionStr"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["projectNAME"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["workJobStr"]) + "</td>\n" +
                                "            <td>" + checkInner(res.obj[x]["locationAddressName"]) + "</td>\n" +
                                "            <td><div class=\"newClass\"><span >调度</span></div><div class='oldClass'><span class='old_rdetails'  staff=" + res.obj[x]['staffId'] + " id=" + res.obj[x]['userId'] + ">历史调度信息</span></div></td>\n" +
                                "        </tr>"
                        }
                        $("#j_tb").html(str);
                        // ----------------------------------------表格添加完成
                        $(".bottom").html("<div class=\"allTrue\"><input type=\"checkbox\" id=\"allChoose\" style=\"margin-left: 22px;\"/>全选</div>\n" +
                            "        <div class=\"dispatchAll\">\n" +
                            "            批量调度\n" +
                            "        </div>");
                        // ----------------------------------------------下方调度按钮完成
                        me.pageTwo(res.totleNum, me.data.pageSize, me.data.page);
                        // ----------------------------------
                        $(".newClass").click(function () {
                            //是否有权限使用事务、短信提醒
                            $.ajax({
                                type:'get',
                                url:'/smsRemind/getRemindFlag',
                                dataType:'json',
                                data:{
                                    type:32
                                },
                                success:function (res) {
                                    if(res.flag){
                                        if(res.obj.length>0){
                                            var data = res.obj[0];
                                            // 是否默事务提醒认发送
                                            if(data.isRemind=='0'){
                                                $('.openShut').prop("checked", false);
                                            }else if(data.isRemind=='1'){
                                                $('.openShut').prop("checked", true);
                                            }
                                            // 是否允许发送事务提醒
                                            if(data.isCan=='0'){
                                                $('#reminds').hide();
                                                $('.openShut').prop("checked", false);
                                            }
                                        }
                                    }
                                }
                            })
                            var singleDispatch = {
                                Id: $(this).parent().siblings().eq(1).attr('id'),
                                Name: $(this).parent().siblings().eq(1).html(),
                                staffId: $(this).parent().siblings().eq(1).attr('staff'),
                                deptName: $(this).parent().siblings().eq(2).html()
                            };
                            get_pro_loca_fun();
                            reminderData();
                            var innerStr = singleDispatch.deptName + '(1人):' + singleDispatch.Name;
                            // $("#userDept").val(innerStr);
                            $("#userDept").val(singleDispatch.Name);
                            $("#userDept").attr("user_id", singleDispatch.Id);
                            $("#userDept").attr("staff", singleDispatch.staffId);
                        });
                        // --------------------------------------

                        // ----------历史调度信息------------------------
                        // $(".oldClass").click(function () {
                        //     var singleDispatch = {
                        //         Id: $(this).parent().siblings().eq(1).attr('id'),
                        //         Name: $(this).parent().siblings().eq(1).html(),
                        //         staffId: $(this).parent().siblings().eq(1).attr('staff'),
                        //         deptName: $(this).parent().siblings().eq(2).html()
                        //     };
                        //     get_pro_loca_fun();
                        //     reminderData();
                        //     var innerStr = singleDispatch.deptName + '(1人):' + singleDispatch.Name;
                        //     // $("#userDept").val(innerStr);
                        //     $("#userDept").val(singleDispatch.Name);
                        //     $("#userDept").attr("user_id", singleDispatch.Id);
                        //     $("#userDept").attr("staff", singleDispatch.staffId);
                        // });
                        // --------------------------------------
                        chooseAll();
                        var dispatchAll = document.getElementsByClassName("dispatchAll")[0];
                        dispatchAll.onclick = function () {
                            var Arr1 = [];
                            for (var x = 0; x < $(".childCheck").length; x++) {
                                if ($(".childCheck").eq(x).prop("checked")) {
                                    Arr1.push(x);
                                }
                            }
                            if (Arr1.length == 0) {
                                layer.confirm('请至少选择一人调度！', {
                                    btn: ['确定'],//按钮
                                    title: '提示'
                                }, function () {
                                    layer.closeAll();
                                });
                            } else {
                                var chooseArr = uniq(Arr1);
                                get_pro_loca_fun();
                                reminderData();
                                var textStr = [];
                                for (var inpVal = 0; inpVal < chooseArr.length; inpVal++) {
                                    userId = $("#j_tb tr").eq(chooseArr[inpVal]).children().eq(1).attr('id');
                                    userName = $("#j_tb tr").eq(chooseArr[inpVal]).children().eq(1).html();
                                    staffId = $("#j_tb tr").eq(chooseArr[inpVal]).children().eq(1).attr('staff');
                                    deptName = $("#j_tb tr").eq(chooseArr[inpVal]).children().eq(2).html();
                                    textStr.push({id: userId, name: userName, staffId: staffId, deptName: deptName})
                                }
                                var textUserId = "";
                                var textStaffId = "";
                                for (var a in textStr) {
                                    textUserId += textStr[a]["id"] + ",";
                                    textStaffId += textStr[a]["staffId"] + ","
                                }
                                var ddaa = checkDept(textStr);
                                $("#userDept").val(getStr(ddaa));
                                $("#userDept").attr("user_id", textUserId);
                                $("#userDept").attr("staff", textStaffId);
                            }
                        };
                        chooseStyle();
                    }
                })
            },
            pageTwo: function (totalData, pageSize, indexs) {
                var mes = this;
                $('#dbgz_page').pagination({
                    totalData: totalData,
                    showData: pageSize,
                    jump: true,
                    coping: true,
                    homePage: '',
                    endPage: '',
                    current: indexs || 1,
                    callback: function (index) {
                        mes.data.page = index.getCurrent();
                        mes.page();
                    }
                });
            }
        };
        ajaxPageLe.page();

        $('#allChoose').click(function () {
            var state = $(this).prop('checked');
            if (state == true) {
                $(this).prop('checked', true);
                $('.childCheck').prop('checked', true);
            } else {
                $(this).prop('checked', false);
                $('.childCheck').prop('checked', false);
            }
        })
    }

    $(function () {
        ajaxTable({});

    });

    (function dep_user_select() {
        $("#selectDept").on("click", function () {
            dept_id = 'deptment';
            $.popWindow("../../common/selectDept?allDept=1");
        });

        $(document).on("click", '#adduser',function () {
            user_id = 'userDept';
            $.popWindow("../../common/selectUser");
        });

        $(document).on("click", '#clearadduser',function () {
            $('#userDept').attr('user_id', '');
            $('#userDept').attr('userprivname', '');
            $('#userDept').removeAttr('dataid');
            $('#userDept').val('');
        });

        function clearDept() {
            $('#deptment').removeAttr('deptid');
            $('#deptment').attr('dataid', '');
            $('#deptment').removeAttr('deptno');
            $('#deptment').val('');
        }

        $('#clearDept').click(function () {
            clearDept();
        });
        $("#selectUser").on("click", function () {
            user_id = 'userDuser';
            $.popWindow("../../common/selectUser");
        });

        function clearUser() {
            $('#userDuser').attr('user_id', '');
            $('#userDuser').attr('userprivname', '');
            $('#userDuser').removeAttr('dataid');
            $('#userDuser').val('');
        }

        $('#clearUser').click(function () {
            clearUser();
        });
    })();
    $(function () {
        get_pro_loca_fun();
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserPost",
            success: function (data) {
                $('#jobPosition').html('');
                $("#jobPosition").append("<option id=''>请选择..</optionid>")

                for (var x = 0; x < data.obj.length; x++) {
                    $("#jobPosition").append("<option id=" + data.obj[x]['postId'] + ">" + data.obj[x]["postName"] + "</option>");
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserJob",
            success: function (data) {
                $("#workJob").html('');
                $("#workJob").append("<option id=''>请选择..</optionid>")

                for (var x = 0; x < data.obj.length; x++) {
                    $("#workJob").append("<option id=" + data.obj[x]['jobId'] + ">" + data.obj[x]["jobName"] + "</option>");
                }
            }
        });
        var projectInp = document.getElementsByClassName("project")[0];
        var locationInp = document.getElementsByClassName("location")[0];
        var jobPosition = document.getElementById("jobPosition");
        var workJob = document.getElementById("workJob");
        $("#checkOut").click(function () {
            var projectIndex = projectInp.selectedIndex;
            var locationIndex = locationInp.selectedIndex;
            var jobPositionIndex = jobPosition.selectedIndex;
            var workJobIndex = workJob.selectedIndex;

            var projectValue = projectInp.options[projectIndex].id;
            var locationValue = locationInp.options[locationIndex].id;
            var jobPositionValue;
            if (jobPosition.options[jobPositionIndex].value == '请选择..') {
                jobPositionValue = '';
            } else {
                jobPositionValue = jobPosition.options[jobPositionIndex].id;
            }
            var workJobValue = workJob.options[workJobIndex].id;
            var data1 = {
                projectName: projectValue,                          //ok
                deptId: $("#deptment").attr('deptid'),              //ok
                position: jobPositionValue,                         //position
                workJob: workJobValue,                                 //post
                locationAddress: locationValue,                     //ok
                userId: $("#userDuser").attr('user_id')              //ok
            };
            ajaxTable(data1);
            $.layerMsg({content: '查询成功！', icon: 1});
        });
    });

    // 历史调度信息




    function reminderData() {
        // event.stopPropagation();
        layer.open({
            type: 1,
            title: ['人事调度', 'background-color:#2b7fe0;color:#fff;'],
            area: ['800px', '80%'],
            shadeClose: true, //点击遮罩关闭
            btn: ['确定', '关闭'],
            content:
                "    <div id='reminds' class='layuiDiv' style='text-align:left;margin-left:179px;'>\n" +
                "        <span>是否开启事务提醒</span>&nbsp;&nbsp;&nbsp;<input type='checkbox' value='0' class='openShut'/>\n" +
                "\n" +
                "    </div>"+
                "<div class='layuiDiv'>\n" +
                "        <span style='margin-left: 46px;'>被调人员：</span><textarea name=\"txt\" staff='' id=\"userDept\" user_id=\"\" value='' disabled=\"\" style=\"min-width: 400px;min-height:280px;font-size:18px\"></textarea>\n" +
                "    <a id='adduser' href='javascript:;' style='color:#1772c0'>添加</a><a id='clearadduser' href='javascript:;' style='color:#1772c0;margin-left: 5px'>清空</a></div>" +
                "    <div class='layuiDiv'>\n" +
                "        <span style='margin-left: 40px'>职务：</span><select class=\"jobPosition\" style='width:400px;'><option>请选择..</option></select>\n" +
                "    </div>\n" +
                "    <div class='layuiDiv'>\n" +
                "        <span style='margin-left: 40px'>岗位：</span><select class='workJob' style='width:400px;'><option>请选择..</option></select>\n" +
                "    </div>\n" +
                "    <div class='layuiDiv'>\n" +
                "        <span>分配项目：</span><select class=\"project\" style='width:400px;'><option>请选择..</option></select>\n" +
                "    </div>\n" +
                "    <div class='layuiDiv'>\n" +
                "        <span>目标地点：</span><select class=\"location\" style='width:400px;'><option>请选择..</option></select>\n" +
                "\n" +
                "    </div>",
                /*"    <div class='layuiDiv'>\n" +
                "        <span>考核分数：</span><input class='assessScore' type='text' style='width: 400px;'/>\n" +
                "\n" +
                "    </div>"+
                "    <div class='layuiDiv'>\n" +
                "        <span>考核评价：</span><textarea  class='assessment' style='vertical-align: middle;min-width: 400px;font-size:18px;min-height:80px ;'></textarea>\n" +
                "\n" +
                "    </div>",*/
            yes: function (index) {
                var projectInp1 = document.getElementsByClassName("project")[1];
                var locationInp1 = document.getElementsByClassName("location")[1];
                var jobPositionInp1 = $(".jobPosition option:selected").attr('id');
                var workJobInp1 = $(".workJob option:selected").attr('id');
                var projectIndex1 = projectInp1.selectedIndex;
                var assessment = $('.assessment').val();
                var assessScore = $('.assessScore').val();
                var openShut = 0;
                if($('.openShut').is(':checked')){
                    openShut = 1;
                }
                projectValue1 = projectInp1.options[projectIndex1].id;
                var locationIndex1 = locationInp1.selectedIndex;
                locationValue1 = locationInp1.options[locationIndex1].id;

                if (projectValue1 == '' && locationValue1 == '' && jobPositionInp1 == '' && workJobInp1 == '' ) {
                    // layer.confirm('请选择分配项目和目标地点后调度！', {
                    //     btn: ['确定'],//按钮
                    //     title: '提示'
                    // }, function () {
                    //     alert('请填写调度信息!');
                        layer.close(layer.index);
                    // });
                } else {
                    var data = {
                        userId: $("#userDept").attr("user_id"),
                        projectName: projectValue1,
                        locationAddress: locationValue1,
                        jobPosition:jobPositionInp1,
                        workJob:workJobInp1,
                        staffId: $("#userDept").attr('staff'),
                        assessment:assessment,
                        assessScore:assessScore,
                        openShut:openShut
                    };
                    $.ajax({
                        url: '/hrPersonnelScheduling/insertHrShedulingLogList',
                        type: 'get',
                        data: data,
                        dataType: 'json',
                        success: function (res) {
                            ajaxTable({});
                            $.layerMsg({content: '调度成功！', icon: 1});
                        }
                    });
                    layer.close(index);
                }

            }
        });
    }

    function get_pro_loca_fun() {
        $.ajax({
            type: 'get',
            url: "/code/getCode",
            data: {"parentNo": "PROJECT_NAME"},
            success: function (data) {
                $('.project').html('');
                $(".project").append("<option id=''>请选择..</optionid>")
                for (var x = 0; x < data.obj.length; x++) {
                    $(".project").append("<option id=" + data.obj[x]["codeId"] + ">" + data.obj[x]["codeName"] + "</optionid>")
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/code/getCode",
            data: {"parentNo": "LOCATION_ADDRESS"},
            success: function (data) {
                $('.location').html('');
                $(".location").append("<option id=''>请选择..</optionid>")
                for (var x = 0; x < data.obj.length; x++) {
                    $(".location").append("<option id=" + data.obj[x]["codeId"] + ">" + data.obj[x]["codeName"] + "</option>")
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserPost",
            success: function (data) {
                $('.jobPosition').html('');
                $(".jobPosition").append("<option id=''>请选择..</optionid>")

                for (var x = 0; x < data.obj.length; x++) {
                    $(".jobPosition").append("<option id=" + data.obj[x]['postId'] + ">" + data.obj[x]["postName"] + "</option>");
                }
            }
        });
        $.ajax({
            type: 'get',
            url: "/hrPersonnelScheduling/getUserJob",
            success: function (data) {
                $(".workJob").html('');
                $(".workJob").append("<option id=''>请选择..</optionid>")

                for (var x = 0; x < data.obj.length; x++) {
                    $(".workJob").append("<option id=" + data.obj[x]['jobId'] + ">" + data.obj[x]["jobName"] + "</option>");
                }
            }
        });
    }

    function chooseAll() {
        var checkTrun = false;
        $("#allChoose").click(function () {
            if (checkTrun == false) {
                checkTrun = true;
                $("tbody tr td input").prop("checked", true);
            } else if (checkTrun == true) {
                checkTrun = false;
                $("tbody tr td input").prop("checked", false);
            }
        });
    }

    function chooseStyle() {
        // var tdWidth = parseInt($(".checkWrap").css("width"));
        $(".allTrue").css({width: '82px'});
        window.onresize = function () {
            tdWidth = parseInt($(".checkWrap").css("width"));
            $(".allTrue").css({width: tdWidth});
        };
    }

    function uniq(array) {
        var temp = []; //一个新的临时数组
        for (var i = 0; i < array.length; i++) {
            if (temp.indexOf(array[i]) == -1) {
                temp.push(array[i]);
            }
        }
        return temp;
    }
</script>
</html>